//
//  ViewController.m
//  Appsetting
//
//  Created by student on 16/3/16.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UILabel *username;
@property (weak, nonatomic) IBOutlet UILabel *password;
@property (weak, nonatomic) IBOutlet UILabel *protocol;
@property (weak, nonatomic) IBOutlet UILabel *warp;
@property (weak, nonatomic) IBOutlet UILabel *warpspeed;
@property (weak, nonatomic) IBOutlet UILabel *tea;
@property (weak, nonatomic) IBOutlet UILabel *candy;
@property (weak, nonatomic) IBOutlet UILabel *game;
@property (weak, nonatomic) IBOutlet UILabel *excuse;
@property (weak, nonatomic) IBOutlet UILabel *sin;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self updateInfo];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateInfo) name:UIApplicationWillEnterForegroundNotification object:nil];
}
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self updateInfo];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)updateInfo
{
    NSUserDefaults *d = [NSUserDefaults standardUserDefaults];
    
    NSLog(@"%@", [d objectForKey:@"username"]);
    NSLog(@"%@",[d valueForKey:@"password"]);
    self.username.text = [d valueForKey:@"username"];
    self.password.text = [d valueForKey:@"password"];
    self.protocol.text = [d valueForKey:@"protocol"];
    self.warp.text = [d boolForKey:@"wrap"]?@"开":@"关";
    self.warp.text = [NSString stringWithFormat:@"%f",[d floatForKey:@"wrapSpeed"]];
    
    self.tea.text = [d valueForKey:@"favoriteTea"];
    self.candy.text = [d valueForKey:@"favoriteCandy"];
    self.game.text = [d valueForKey:@"favoriteGame"];
    self.excuse.text = [d valueForKey:@"favoriteExcuse"];
    self.sin.text = [d valueForKey:@"favoriteSin"];
    
}


@end
